﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Examples
{
    /// <summary>
    /// Exports given list and view, if provided, to CamelotXml with CDATA brackets around string content
    /// </summary>
    class ExportListAsCamelotXmlUsingCData
    {
        public static void DoIt(string connectionString, string listName, string viewName, string xmlFile)
        {
            using (var connection = new Camelot.SharePointConnector.Data.SharePointConnection(connectionString))
            {
                connection.Open();

                var data = Camelot.SharePointIntegration.ListDataUtility.CreateListData(listName, viewName, false, connection);
                var xml = Camelot.SharePointIntegration.Client.CamelotXml.CreateXml(data, true);

                System.IO.File.WriteAllText(xmlFile, xml, Encoding.UTF8);
            }
        }
    }
}
